package 剑指offer;

import java.util.List;

public class Offer05_JZ02 {
    public static void main(String[] args) {
        System.out.println(replaceSpace(new StringBuffer("we are happy")));
    }

    public static String replaceSpace(StringBuffer str) {
        StringBuilder stringBuilder = new StringBuilder();
        String s = "%20";
        for(int i=0; i<str.length(); i++) {
            if(' ' == str.charAt(i)) {
                stringBuilder.append(s);
            } else {
                stringBuilder.append(str.charAt(i));
            }
        }
        return stringBuilder.toString();
    }
}
